﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using IDAL;
using System.Reflection;

namespace DALFactory
{
     public class DataAccess
    {
         private static readonly string path = System.Configuration.ConfigurationManager.AppSettings["DAL"];

         ///<summary>
         ///创建User数据接口层
         ///</summary>
         public static IDAL.IUser CreateUser()
         {
             string classname = path + ".User";
             return (IDAL.IUser)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.ILogin CreateLogin()
         {
             string classname = path + ".Login";
             return (IDAL.ILogin)Assembly.Load(path).CreateInstance(classname);
         }
         public static IDAL.ITeacher CreateTeacher()
         {
             string classname = path + ".Teacher";
             return (IDAL.ITeacher)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.INews CreateNews()
         {
             string classname = path + ".News";
             return (IDAL.INews)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.IPicture CreatePicture()
         {
             string classname = path + ".Picture";
             return (IDAL.IPicture)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.IOrder CreateOrder()
         {
             string classname = path + ".Order";
             return (IDAL.IOrder)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.IAdmin CreateAdmin()
         {
             string classname = path + ".Admin";
             return (IDAL.IAdmin)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.ILog CreateLog()
         {
             string classname = path + ".Log";
             return (IDAL.ILog)Assembly.Load(path).CreateInstance(classname);
         }

         public static IDAL.IUserCourse CreateUserCourse()
         {
             string classname = path + ".UserCourse";
             return (IDAL.IUserCourse)Assembly.Load(path).CreateInstance(classname);
         }

         
    }
}
